KitePlayerPictureInPicture

Puts the canvas a web player draws into in a small window above the viewer's other windows.

createOrNull picks the first of two browser features that this browser has:

  1. WebPictureInPictureMode.DocumentWindow. The canvas itself moves into the window, so everything the renderer draws comes along. An empty element of the canvas's size, with the class kiteplayer-pip-placeholder, keeps its place in the page. When the window closes, the canvas goes back in its place.

  2. WebPictureInPictureMode.VideoElement. A hidden, muted video element plays a live capture of the canvas, and the window's play and pause buttons play and pause the player.

A browser opens the window only inside the viewer's own click, so start asks at once and never suspends. Call it from the click handler itself, with nothing awaited before it.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val active: StateFlow<Boolean>

isActive, as a flow that changes when the window opens and when it closes.

Link copied to clipboard

True while the small window is on screen.

Link copied to clipboard

True when the browser would open the window now. The video element feature also needs the capture to have delivered a frame, so it is false until the player has drawn one.

Link copied to clipboard

The browser feature start uses, or null once close has run.

Functions

Link copied to clipboard
open override fun close()

Calls stop, releases what createOrNull prepared, and refuses every later start.

Link copied to clipboard
fun start()

Asks the browser for the window. It opens later, when the browser grants it; watch active.

Link copied to clipboard
fun stop()

Closes the window and puts the picture back in the page.